package com.sky.mapper;

import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author OZ.L.XO
 * #Description ShoppingCartMapper
 * #Date: 2025/7/10 16:45
 */
@Mapper
public interface ShoppingCartMapper {
    /**
     * @Description 查看购物车
     * @Param [shoppingCart]
     * @Return void
     */
    List<ShoppingCart> list(ShoppingCart shoppingCart);

    /**
     * @Description 根据ID更新商品数量
     * @Param [shoppingCart]
     * @Return void
     */
    @Update("update shopping_cart set number =#{number} where id=#{id}")
    void updateNumberById(ShoppingCart shoppingCart);

    /**
     * @Description 插入购物车数据
     * @Param [shoppingCart]
     * @Return void
     */
    @Insert("insert into shopping_cart (name, image,user_id, dish_id, setmeal_id, dish_flavor, number, amount, create_time) " +
    "values (#{name}, #{image},#{userId}, #{dishId}, #{setmealId}, #{dishFlavor}, #{number}, #{amount}, #{createTime})")
    void insert(ShoppingCart shoppingCart);

    /**
     * @Description 根据菜品id删除购物车
     * @Param [userId]
     * @Return java.util.List<com.sky.entity.ShoppingCart>
     */
    @Delete("delete from shopping_cart where dish_id = #{id}")
    void deleteByDishId(Long id);

    /**
     * @Description 根据套餐id删除购物车
     * @Param [userId]
     * @Return java.util.List<com.sky.entity.ShoppingCart>
     */
    @Delete("delete from shopping_cart where setmeal_id = #{id}")
    void deleteBySetmealId(Long setmealId);

    /**
     * @Description 清空购物车
     * @Param [userId]
     * @Return void
     */
    @Delete("delete from shopping_cart where user_id = #{userId}")
    void cleanShoppingCart(Long userId);

    /**
     * @Description 批量插入购物车数据
     * @Param [shoppingCart]
     * @Return void
     */
    void insertBatch(List<ShoppingCart> shoppingCartList);
}











